#!/bin/sh
# omindextest: Test omindex
#
# Copyright (C) 2019 Bruno Baruffaldi
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
# USA

set -e

: ${OMINDEX=./omindex}
: ${XAPIAN_OMEGA_PKGLIBBINDIR=.}
export XAPIAN_OMEGA_PKGLIBBINDIR

# Don't complain about memory left allocated on exit - the OS will reclaim
# all memory at that point.
LSAN_OPTIONS=leak_check_at_exit=0
export LSAN_OPTIONS

srcdir=`echo "$0"|sed 's!/*[^/]*$!!'`
TEST_FILES="$srcdir/testfiles/"
TEST_DB="testdatabase"

trap 'rm -rf "$TEST_DB"' 0 1 2 13 15

$OMINDEX --overwrite --db "$TEST_DB" --url=/ "$TEST_FILES"
./omindexcheck "$TEST_DB"
